There are different ways to access the Report Designer Component (RDC) and any other COM Automation server through Visual C++. This section describes how to use the #import method.
Manipulating the RDC in Microsoft Visual C++ involves three steps:
The following section leads you through the details in each of these steps.
#import "C:\Program Files\Seagate Software\Crystal Reports\Developer Files\include\craxdrt.tlb"
Note: This is the default location of the RDC runtime object model (craxdrt.dll).
struct InitOle { InitOle() { ::CoInitialize(NULL); } ~InitOle() { ::CoUninitialize(); } } _init_InitOle_;
Variant dummy;
// The constants needed to create the Application and Report Objects COM objects const CLSID CLSID_Application = {0xb4741fd0,0x45a6,0x11d1,{0xab,0xec,0x00,0xa0,0xc9,0x27,0x4b,0x91}}; const IID IID_IApplication = {0x0bac5cf2,0x44c9,0x11d1,{0xab,0xec,0x00,0xa0,0xc9,0x27,0x4b,0x91}}; const CLSID CLSID_ReportObjects = {0xb4741e60,0x45a6,0x11d1,{0xab,0xec,0x00,0xa0,0xc9,0x27,0x4b,0x91}}; const IID IID_IReportObjects = {0x0bac59b2,0x44c9,0x11d1,{0xab,0xec,0x00,0xa0,0xc9,0x27,0x4b,0x91}};
// A dummy variant VariantInit (&dummy); dummy.vt = VT_EMPTY; HRESULT hr = S_OK; IApplicationPtr m_Application = NULL; IReportPtr m_Report = NULL; // Specify the path to the report you want to print _bstr_t ReportPath("c:\\Program Files\\Seagate Software\\Crystal Reports\\Samples\\En\\Reports\\General Business\\Inventory.rpt"); _variant_t vtEmpty(DISP_E_PARAMNOTFOUND, VT_ERROR); // Instantiate the IApplication object hr = CoCreateInstance(CLSID_Application, NULL, CLSCTX_INPROC_SERVER , IID_IApplication, (void **) & CRAXDRT::IApplication); //Open the Report using the OpenReport method m_Report = m_Application->OpenReport(ReportPath, dummy) //Print the Report to printer m_Report->PrintOut(dummy, dummy, dummy, dummy
);
There are hundreds of properties, methods, and events in the Report Designer Component object model that you can manipulate through your code to meet the demands of virtually any reporting requirement.
Seagate Software IMG Holdings, Inc. http://www.seagatesoftware.com Support services: http://support.seagatesoftware.com |